{% extends 'userbase.html' %}
{% load staticfiles %}
{% block framework %}
<div class="cw1000">
	<div class="public_box pd30">
		<div class="public_tag">
			<ul>
				<li><a {% if is_published == 'published' %}class="cur"{% endif %} href="{% url 'diarys:mydetails' 'published' %}">已发表游记</a></li>
				<li><a {% if is_published == 'draft' %}class="cur"{% endif %} href="{% url 'diarys:mydetails' 'draft' %}">我的草稿</a></li>
				<div class="clear"></div>
			</ul>
		</div>

            <script type="text/javascript">
                function deldiary(diary_id)
                    {
                         $.ajaxSetup({headers: {"X-CSRFToken": '{{ csrf_token }}'}});
                         $.ajax({
                             type: "POST",
                             data: {'id': diary_id},
                             url: '{% url 'diarys:delete' %}',
                             cache: false,
                             dataType: "json",
                             success:function (data) {
                                 if(data.status == "success"){
                                     alert('删除成功！')
                                     {#局部刷新#}
                                     $(".note_list").load(location.href + " .note_list");
                                 }
                                 else
                                 {
                                     alert('删除失败！')
                                 }
                             },
                             error:function (){
                                 alert('error')
                             },
                        });
                    }
        </script>
		<!-----------------游记列表---------------->
		<div class="note_list">
			<ul>
                {% for diary in diarys %}
				<li class="pd_r150">
					<div class="pic"><img src="{{ MEDIA_URL }}{{ diary.image }}"/></div>
					<div class="con">
						<a href="{% if is_published == 'published' %}
                                {% url 'diarys:details' diary.id %}
                                {% elif is_published == 'draft' %}
                                {% url 'diarys:getdiaray' diary.id %}
                                {% endif %}">
                            <h3>{{ diary.title }}</h3></a>
						<div class="user">
							<span><img src="{{ MEDIA_URL }}{{ diary.user.portrait }}" />作者：<font>{{ diary.user.nickname }}</font></span>
							<label><img src="{% static 'images/state_icon1.png' %}" />{{ diary.checknum }}</label>
							<label><img src="{% static 'images/state_icon2.png' %}" />{{ diary.commentsnum }}</label>
						</div>
						<p>{{ diary.content|striptags|truncatechars:"100"  }}</p>
					</div>
					<div class="operation">
                        {% if is_published == 'draft' %}
                            <a href="{% url 'diarys:publish' diary.id %}"><i class="express_ico"></i>发表</a>
                        {% endif %}
						<a href="{% url 'diarys:getdiaray' diary.id %}"><i class="edit_ico"></i>修改</a>
						<a href="javascript:void(0);" onclick="deldiary({{ diary.id }})"><i class="del_ico" ></i>删除</a>
					</div>
				</li>
                {% endfor %}
			</ul>
		</div>
	</div>
	<div class="clear"></div>
</div>
{% endblock %}

{% block script %}
<script type="text/javascript">
function del1(diary_id)
    {
        alert(diary_id)
    }



</script>
{% endblock %}